package au.com.iglootech.winerymap.entity;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

/**
 * 
 * @author Nicholas Zhu
 * 
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class MyFavorite implements IGTDomainEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7014685108091255364L;
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private Key wineryKey;

	@Persistent
	private Key userKey;

	@Override
	public Key getKey() {
		return this.key;
	}

	@Override
	public void setKey(final Key key) {
		this.key = key;
	}

	@Override
	public String toLogString() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Key createBy() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * @return the wineryKey
	 */
	public Key getWineryKey() {
		return wineryKey;
	}

	/**
	 * @param wineryKey
	 *            the wineryKey to set
	 */
	public void setWineryKey(final Key wineryKey) {
		this.wineryKey = wineryKey;
	}

	/**
	 * @return the userKey
	 */
	public Key getUserKey() {
		return userKey;
	}

	/**
	 * @param userKey
	 *            the userKey to set
	 */
	public void setUserKey(final Key userKey) {
		this.userKey = userKey;
	}

	/**
	 * 
	 * @return string of key
	 */
	public String getKeyValue() {
		return KeyFactory.keyToString(key);
	}

	/**
	 * 
	 * @param keyValue
	 *            string of key
	 */
	public void setKeyValue(final String keyValue) {
		key = KeyFactory.stringToKey(keyValue);
	}

}
